<template>
  <div class="app-container">
    <el-form :model="searchForm" ref="queryForm" size="small" :inline="true"   label-width="68px">
      <el-form-item label="姓名" prop="name">
        <el-input   placeholder="请输入姓名"   clearable    />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="search">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="selectItems">选择</el-button>
      </el-form-item>
    </el-form>
    <el-table
      v-loading="listLoading"
      :data="list"
      element-loading-text="加载中..."
      @select="selectionChange"
      border
      fit
      highlight-current-row
    >
      <el-table-column align="center" type="selection" label="选择" width="95">  </el-table-column>
      <el-table-column align="center" type="index" label="序号" width="95">  </el-table-column>
      <!--      <el-table-column align="center" prop="checkId" label="checkId" width="95">  </el-table-column>-->
      <el-table-column align="center" prop="name" label="检查项目名称">  </el-table-column>
      <el-table-column align="center" prop="price" label="费用/单价"  >  </el-table-column>

    </el-table>


    <el-pagination
      background
      @current-change="fetchData()"
      layout="prev, pager, next,sizes"
      :page-sizes="[5, 10, 20, 50]"
      :current-page.sync="searchForm.pageNo"
      :page-size.sync="searchForm.size"
      :total="searchForm.total">
    </el-pagination>



  </div>
</template>

<script>
import { getList ,deleteById } from '@/api/item_manager/checkitem'
export default {
  name:'ChooiceCheckItems',
  props:["visible"],
  data() {
    return {
      dialogTitle:'',
      searchForm:{
        pageNo:1,
        size:10,
        total:0,
        dname:''
      },
      id:'',
      list: null,
      listLoading: true,
      selection:[]
    }
  },
  created() {
    this.fetchData()
  },
  methods: {
    selectionChange(selection){
      this.selection = selection;
    },
    selectItems(){
      this.$emit("selectCheckItem", this.selection)
      this.$emit("update:visible",false)
    },
    search() {
      this.fetchData()
    },
    fetchData() {
      this.listLoading = true
      let param = {
        pageNo: this.searchForm.pageNo,
        size: this.searchForm.size,
        dname: this.searchForm.dname
      }


      getList(param).then(page => {
        this.list = page.data;

        let {total, pages, size, pageNo} = page;
        this.searchForm.total = total

        this.listLoading = false
      })
    },


  }
}
</script>
